<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<jsp:include page="../common/ListUIHead.jsp"></jsp:include>
	<title>点餐汇总</title>
</head>
<body style="padding:1px 3px 1px 3px;overflow:hidden">
	<div id="main">
		<div position="center">
			<div id="toolBar">
			</div>
			<div id="tableContainer">
			</div>
	    </div>
    </div>
</body>
</html>
<script type="text/javascript">
	var data = eval('('+'${page}'+')');
    $(function(){
    	$("#main").ligerLayout({});
        $list_dataGrid = $("#tableContainer").ligerGrid($.extend($list_defaultGridParam,{
            columns: [ 
            	{display: '餐馆', name: 'restaurant.name', align: 'left', width: 80},
            	{display: '电话', name: 'restaurant.phone', align: 'left', width: 80},
            	{display: '菜式', name: 'dishes.name', align: 'left', width: 80},
            	{display: '份数', name: 'count', align: 'right', width: 80,totalSummary:{type:'sum', align: 'right'}},
            	{display: '小计', name: 'sum', align: 'right', width: 80,totalSummary:{type:'sum', align: 'right'}}
	        ],
	        rownumbers:false,
	        usePager:false,
            data:data,
            onAfterShowData:function(g,d,e){
            	mergecell("#tableContainer","c101");
            	mergecell("#tableContainer","c102");
            }
        }));
    });
    function mergecell(gridid,columnid){//参数:表格id和列索引关键字，根据表格具体值来动态合并单元格
	   var i,j,k,x;
	   i=-1;k=1;j="";x=0;
	   var cellname="";
	   $("td[id$='|"+columnid+"']",gridid).each(
		   function (){                         
			if(j==$("div",this).text()){
			    $(this).addClass("l-remove");
			    k++;                            
			    $("td[id='"+cellname+"']",gridid).attr("rowspan",k.toString());                            
			}else{
			    j=$("div",this).text();                            
			    var a= $(this);
			    cellname = a.attr("id");//得到点击处的id                            
			    k=1;
			    x=i;
			}
			i++;                                         
	   });                 
	   $(".l-remove").remove();            
	}
</script>